package com.cx.dao;

import com.cx.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface UserMapper {

    //    查询所有用户以及管理的角色
//    @Select("select * from t_user")
    public List<User> getAllUser(@Param("st") Integer currentPage,@Param("pageSize") Integer pageSize);

    //    查询总记录数
    @Select("select count(*) from t_user u, t_role r where u.rid=r.rid")
    public int count();

    //    用户登录，根据用户名和密码查询
    @Select("select * from t_user where NAME=#{name} and PASSWORD = #{password} and rid = #{rid}")
    public User login(User user);


    //    根据id删除指定的用户信息
    @Delete("delete from t_user where id = #{id}")
    public void deleteUserById(Integer id);

    //    根据用户名查询指定的用户信息
    @Select("select  * from t_user where NAME = #{name}")
    public User checkName(String name);

    //    添加用户
    @Insert("insert into t_user (NAME, PASSWORD, age, birthday, gender, phone, QQNumber,rid) " +
            "values (#{name},#{password},#{age},#{birthday},#{gender},#{phone},#{QQNumber},#{rid});")
    public void addUser(User user);

//    根据id查询指定的用户信息
//    @Select("select  * from t_user where id = #{id}")
    public User getUserById(Integer id);

    //    根据id修改用户信息
    @Update("update t_user set NAME=#{name}, PASSWORD = #{password}, age = #{age}, birthday = #{birthday}, rid = #{rid} where id=#{id}")
    public void updateUser(User user);
}
